/*     */ package com.qmsk.business.bussBill.bpCheck.controller;
/*     */ 
/*     */ import com.qmsk.business.bussBill.bussBill.dao.BussBillDao;
/*     */ import com.qmsk.business.bussBill.pbPaid.PbPaid;
/*     */ import com.qmsk.business.member.bussbilldisctcouponpay.dao.BussBillDisctCouPonPayDao;
/*     */ import com.qmsk.business.member.bussbillpaycheck.dao.BussBillPayCheckDao;
/*     */ import com.qmsk.business.member.bussbillpaypos.dao.BussBillPayPosDAO;
/*     */ import com.qmsk.business.member.custSMS.bean.CustMessage;
/*     */ import com.qmsk.business.member.member.dao.MemberDAO;
/*     */ import com.qmsk.business.member.memberAct.MemberActConst;
/*     */ import com.qmsk.business.member.memberCashCoupConsumeRecord.dao.MemberCashCouponConsumeRecordDAO;
/*     */ import com.qmsk.business.member.memberCashCoupDetail.dao.MemberCashCouponDetailDAO;
/*     */ import com.qmsk.business.member.memberIntegralConsumeRecord.dao.MemberIntegralConsumeRecordDAO;
/*     */ import com.qmsk.business.member.memberIntegralDetail.dao.MemberIntegralDetailDAO;
/*     */ import com.qmsk.business.member.memberLog.dao.MemberLogDAO;
/*     */ import com.qmsk.session.UserSessionInfo;
/*     */ import com.qmsk.session.bean.CSessionUser;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadManyRows;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.http.HttpGsonPtResponseUtils;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"bpCheck"})
/*     */ public class BpCheckController
/*     */ {
/*  49 */   private static final Logger logger = Logger.getLogger(BpCheckController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralDetailDAO integralDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberLogDAO memberLogDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberDAO memberDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralConsumeRecordDAO integralConsumeRecordDAO;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillDisctCouPonPayDao bussbilldiscpayDao;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillPayCheckDao bussbillpaycheckDao;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillPayPosDAO bussbillPayPosDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberCashCouponDetailDAO memberCashCouponDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberCashCouponConsumeRecordDAO memberCashCouponConsumeRecordDAO;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  96 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  98 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/*  99 */         nPageSize);
/* 100 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 102 */       logger.error(e);
/* 103 */       ResponseUtils.setErrorMsgResponse(
/* 104 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/stId/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdStId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 114 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 116 */       int stId = 5;
/* 117 */       Map params = new HashMap();
/* 118 */       params.put("shopId", shopId);
/* 119 */       params.put("stId", Integer.valueOf(stId));
/* 120 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdStId(params, nPageIdx, 
/* 121 */         nPageSize);
/* 122 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 124 */       logger.error(e);
/* 125 */       ResponseUtils.setErrorMsgResponse(
/* 126 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/stId/cust/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdStIdCust(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 136 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 138 */       int stId = 5;
/* 139 */       Map params = new HashMap();
/* 140 */       MapUtils.addToMap(params, "shopId", shopId);
/* 141 */       MapUtils.addToMap(params, "stId", Integer.valueOf(stId));
/* 142 */       MapUtils.addToMap(params, "paid", 
/* 143 */         RequestUtils.getInt(request, "paid"));
/* 144 */       MapUtils.addPercentToMap(params, "custName", 
/* 145 */         RequestUtils.getString(request, "custName"));
/* 146 */       MapUtils.addPercentToMap(params, "license", 
/* 147 */         RequestUtils.getString(request, "license"));
/* 148 */       MapUtils.addPercentToMap(params, "billNo", 
/* 149 */         RequestUtils.getString(request, "billNo"));
/* 150 */       MapUtils.addToMap(params, "createTimeStart", 
/* 151 */         RequestUtils.getDate(request, "createTimeStart"));
/* 152 */       MapUtils.addToMap(params, "createTimeEnd", 
/* 153 */         RequestUtils.getDate(request, "createTimeEnd"));
/* 154 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdStId(params, nPageIdx, 
/* 155 */         nPageSize);
/* 156 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 158 */       logger.error(e);
/* 159 */       ResponseUtils.setErrorMsgResponse(
/* 160 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/stId/paid/date/sum"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getSumShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*     */   {
/*     */     try
/*     */     {
/* 175 */       Map params = new HashMap();
/* 176 */       MapUtils.addToMap(params, "shopId", shopId);
/* 177 */       MapUtils.addToMap(params, "stId", 
/* 178 */         RequestUtils.getInt(request, "stId"));
/* 179 */       MapUtils.addToMap(params, "paid", 
/* 180 */         RequestUtils.getInt(request, "paid"));
/* 181 */       MapUtils.addToMap(params, "dtPaidStart", 
/* 182 */         RequestUtils.getDate(request, "dtPaidStart"));
/* 183 */       MapUtils.addToMap(params, "dtPaidEnd", 
/* 184 */         RequestUtils.getDate(request, "dtPaidEnd"));
/* 185 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId_StId_Sum_Date(params);
/* 186 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 188 */       logger.error(e);
/* 189 */       ResponseUtils.setErrorMsgResponse(
/* 190 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/stId/paid/date/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdStIdDate(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 207 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 209 */       Map params = new HashMap();
/* 210 */       MapUtils.addToMap(params, "shopId", shopId);
/* 211 */       MapUtils.addToMap(params, "saleId", RequestUtils.getLong(request, "saleId"));
/* 212 */       MapUtils.addToMap(params, "stId", RequestUtils.getInt(request, "stId"));
/* 213 */       MapUtils.addToMap(params, "paid", RequestUtils.getInt(request, "paid"));
/* 214 */       MapUtils.addToMap(params, "dtPaidStart", RequestUtils.getDate(request, "dtPaidStart"));
/* 215 */       MapUtils.addToMap(params, "dtPaidEnd", RequestUtils.getDate(request, "dtPaidEnd"));
/* 216 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId_StId_Paid_Date(params, nPageIdx, 
/* 217 */         nPageSize);
/* 218 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 220 */       logger.error(e);
/* 221 */       ResponseUtils.setErrorMsgResponse(
/* 222 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListBussId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Integer bussId)
/*     */   {
/*     */     try
/*     */     {
/* 237 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBussId(bussId);
/* 238 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 240 */       logger.error(e);
/* 241 */       ResponseUtils.setErrorMsgResponse(
/* 242 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 258 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 260 */       String[] strParams = id.split(",");
/* 261 */       int nResult = this.dao.deleteParams(strParams);
/* 262 */       nResult += this.bussbilldiscpayDao.deleteOfbussIds(strParams);
/* 263 */       nResult += this.bussbillpaycheckDao.deleteOfbussIds(strParams);
/* 264 */       nResult += this.bussbillPayPosDao.deleteOfbussIds(strParams);
/* 265 */       if (nResult > 0)
/* 266 */         DbConnection.commit();
/*     */       else {
/* 268 */         DbConnection.rollback();
/*     */       }
/* 270 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 271 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 272 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 275 */       DbConnection.rollback();
/* 276 */       logger.error(e);
/* 277 */       ResponseUtils.setErrorMsgResponse(
/* 278 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 279 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"paid/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void paidCustId(HttpServletRequest request, @PathVariable("shopId") Long shopId, HttpServletResponse response)
/*     */   {
/* 296 */     String id = RequestUtils.getString(request, "id");
/* 297 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/* 298 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/* 299 */     int nResult = 0;
/*     */     try {
/* 301 */       nResult = this.dao.updateBillPaidOfIds(id, userId, userName);
/*     */ 
/* 304 */       if (nResult > 0)
/* 305 */         DbConnection.commit();
/*     */       else {
/* 307 */         DbConnection.rollback();
/*     */       }
/* 309 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 310 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 311 */         response);
/*     */     } catch (Exception e) {
/* 313 */       DbConnection.rollback();
/* 314 */       logger.error(e);
/* 315 */       ResponseUtils.setErrorMsgResponse(
/* 316 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 317 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException
/*     */   {
/* 335 */     String id = RequestUtils.getString(request, "id");
/* 336 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/* 337 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/* 338 */     int nResult = 0;
/*     */     try {
/* 340 */       nResult = this.dao.updateCheckedOfIds(userId, userName, id);
/* 341 */       if (nResult > 0)
/* 342 */         DbConnection.commit();
/*     */       else {
/* 344 */         DbConnection.rollback();
/*     */       }
/* 346 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 347 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 348 */         response);
/*     */     } catch (Exception e) {
/* 350 */       DbConnection.rollback();
/* 351 */       logger.error(e);
/* 352 */       ResponseUtils.setErrorMsgResponse(
/* 353 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 354 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"paid/shopId/{shopId}/member"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void paidMember(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 371 */     String id = RequestUtils.getString(request, "id");
/* 372 */     int nResult = 0;
/* 373 */     Long userId = UserSessionInfo.getIntUserIdOfRequest(request);
/* 374 */     String userName = UserSessionInfo.getUserNameOfRequest(request);
/*     */     try {
/* 376 */       nResult = this.dao.updateBillPaidOfIds(id, userId, userName);
/* 377 */       if (nResult > 0) {
/* 378 */         nResult = paidDetailOfbsbill(id, userId, userName, request, 
/* 379 */           response);
/*     */       }
/* 381 */       if (nResult > 0) {
/* 382 */         DbConnection.commit();
/* 383 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 384 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 385 */           response);
/* 386 */         return; }
/* 387 */       DbConnection.rollback();
/* 388 */       PbPaid.getResponse(nResult, response);
/*     */     }
/*     */     catch (Exception e) {
/* 391 */       DbConnection.rollback();
/* 392 */       logger.error(e);
/* 393 */       ResponseUtils.setErrorMsgResponse(
/* 394 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 395 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   private int paidDetailOfbsbill(String id, Long userId, String userName, HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException, Exception
/*     */   {
/* 402 */     Long bissId = Long.valueOf(id);
/* 403 */     int nResult = 0;
/* 404 */     String memo = "";
/* 405 */     GsonHeadOneRow r = this.dao.getGsonHeadOneRowOfBsbillIds(bissId);
/* 406 */     if (r != null) {
/* 407 */       Long shopId = (Long)r.getValueOfName("shopId");
/* 408 */       Long memberId = (Long)r.getValueOfName("memberId");
/* 409 */       String billNo = (String)r.getValueOfName("billNo");
/* 410 */       Double billAmt = ObjectComm.objectToDouble(
/* 411 */         r.getValueOfName("BillAmt"), Integer.valueOf(0));
/* 412 */       String memo1 = (String)r.getValueOfName("Memo");
/* 413 */       if (memo1 != null) {
/* 414 */         memo = memo1;
/*     */       }
/* 416 */       Double dDeposit = Double.valueOf(0.0D);
/* 417 */       Double dIntAmt = Double.valueOf(0.0D);
/* 418 */       Double dCach = Double.valueOf(0.0D);
/* 419 */       Double payCashMny = Double.valueOf(0.0D);
/* 420 */       Double payDisctCoup = Double.valueOf(0.0D);
/* 421 */       CustMessage csMsg = new CustMessage();
/* 422 */       if (ObjectComm.objectToDouble(r.getValueOfName("ReceAmt"), Integer.valueOf(0)).doubleValue() == 0.0D) {
/* 423 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/* 424 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/* 425 */           userName);
/* 426 */         return 1;
/*     */       }
/* 428 */       Integer stId = ObjectComm.objectToInteger(r.getValueOfName("stID"), 
/* 429 */         Integer.valueOf(0));
/* 430 */       Double payDisct = ObjectComm.objectToDouble(
/* 431 */         r.getValueOfName("PayDisctCoup"), Integer.valueOf(0));
/* 432 */       Integer payIntAmt = ObjectComm.objectToInteger(
/* 433 */         r.getValueOfName("PayIntAmt"), Integer.valueOf(0));
/* 434 */       Double payCash = ObjectComm.objectToDouble(
/* 435 */         r.getValueOfName("PayCash"), Integer.valueOf(0));
/* 436 */       Double payDepstAmt = ObjectComm.objectToDouble(
/* 437 */         r.getValueOfName("PayDepstAmt"), Integer.valueOf(0));
/* 438 */       Double payCheck = ObjectComm.objectToDouble(
/* 439 */         r.getValueOfName("PayCheck"), Integer.valueOf(0));
/* 440 */       Double payCredit = ObjectComm.objectToDouble(
/* 441 */         r.getValueOfName("PayCredit"), Integer.valueOf(0));
/* 442 */       if ((payCredit != null) && (payCredit.doubleValue() > 0.0D)) {
/* 443 */         this.memberLogDAO.insertMemberLogBuss(MemberActConst.PAID, billNo, 
/* 444 */           dIntAmt, dDeposit, dCach, dCach, memberId, userId, 
/* 445 */           userName);
/* 446 */         return 1;
/*     */       }
/* 448 */       Double payPersonCard = ObjectComm.objectToDouble(
/* 449 */         r.getValueOfName("PayPersonCard"), Integer.valueOf(0));
/* 450 */       Double payPos = ObjectComm.objectToDouble(
/* 451 */         r.getValueOfName("PayPos"), Integer.valueOf(0));
/*     */ 
/* 453 */       Double payCashCoupAmtMny = ObjectComm.objectToDouble(
/* 454 */         r.getValueOfName("PayCashCoupAmt"), Integer.valueOf(0));
/* 455 */       if ((payIntAmt != null) && (payIntAmt.intValue() != 0)) {
/* 456 */         dIntAmt = Double.valueOf(dIntAmt.doubleValue() + payIntAmt.intValue());
/*     */       }
/* 458 */       if ((payDepstAmt != null) && (payDepstAmt.doubleValue() != 0.0D)) {
/* 459 */         dDeposit = Double.valueOf(dDeposit.doubleValue() + payDepstAmt.doubleValue());
/*     */       }
/* 461 */       if ((payCash != null) && (payCash.doubleValue() != 0.0D)) {
/* 462 */         dCach = Double.valueOf(dCach.doubleValue() + payCash.doubleValue());
/*     */       }
/* 464 */       if ((payCheck != null) && (payCheck.doubleValue() != 0.0D)) {
/* 465 */         dCach = Double.valueOf(dCach.doubleValue() + payCheck.doubleValue());
/*     */       }
/*     */ 
/* 470 */       if ((payPersonCard != null) && (payPersonCard.doubleValue() != 0.0D)) {
/* 471 */         dCach = Double.valueOf(dCach.doubleValue() + payPersonCard.doubleValue());
/*     */       }
/* 473 */       if ((payPos != null) && (payPos.doubleValue() != 0.0D)) {
/* 474 */         dCach = Double.valueOf(dCach.doubleValue() + payPos.doubleValue());
/*     */       }
/* 476 */       if ((payCashCoupAmtMny != null) && (payCashCoupAmtMny.doubleValue() != 0.0D)) {
/* 477 */         payCashMny = Double.valueOf(payCashMny.doubleValue() + payCashCoupAmtMny.doubleValue());
/*     */       }
/* 479 */       if ((payDisct != null) && (payDisct.doubleValue() != 0.0D))
/* 480 */         payDisctCoup = Double.valueOf(payDisctCoup.doubleValue() + payDisct.doubleValue());
/*     */       GsonHeadManyRows detailIDsRslt;
/*     */       int i;
/*     */   
/*     */       Long detailId;
/* 489 */       if (dIntAmt.doubleValue() > 0.0D) {
/* 490 */         detailIDsRslt = this.integralDetailDAO
/* 491 */           .getSelectMemIntDtialRslt(memberId, shopId);
/* 492 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/* 493 */           Integer memberIntegral = Integer.valueOf(0);
/* 494 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/* 495 */             Integer intAmtTemp = (Integer)detailIDsRslt
/* 496 */               .getValueOfName("Integral", i);
/* 497 */             memberIntegral = Integer.valueOf(memberIntegral.intValue() + intAmtTemp.intValue());
/*     */           }
/* 499 */           if (memberIntegral.intValue() >= dIntAmt.doubleValue()) {
/* 500 */             Integer tempIntAmt = Integer.valueOf(dIntAmt.intValue());
/* 501 */             boolean decIntAmt = true;
/* 502 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/* 503 */               Integer intAmt = (Integer)detailIDsRslt
/* 504 */                 .getValueOfName("Integral", i);
/* 505 */               detailId = (Long)detailIDsRslt
/* 506 */                 .getValueOfName("DetailID", i);
/* 507 */               Integer intLog = Integer.valueOf(0);
/* 508 */               if (tempIntAmt.intValue() - intAmt.intValue() < 0) {
/* 509 */                 intLog = tempIntAmt;
/*     */               }
/* 511 */               tempIntAmt = Integer.valueOf(tempIntAmt.intValue() - intAmt.intValue());
/* 512 */               if (!(decIntAmt)) break;
/* 513 */               if (tempIntAmt.intValue() >= 0)
/*     */               {
/* 515 */                 nResult = nResult + this.integralDetailDAO
/* 515 */                   .updateIntAmtDtlStatusOfID(
/* 516 */                   memberId, detailId);
/*     */ 
/* 518 */                 nResult = nResult + this.integralConsumeRecordDAO
/* 518 */                   .insertIntgCrIt(detailId, billNo, 
/* 519 */                   intAmt, bissId, memo);
/* 520 */                 if (tempIntAmt.intValue() == 0)
/* 521 */                   decIntAmt = false;
/*     */               }
/*     */               else {
/* 524 */                 intAmt = Integer.valueOf(intAmt.intValue() - intLog.intValue());
/*     */ 
/* 526 */                 nResult = nResult + this.integralDetailDAO
/* 526 */                   .updateIntAmtMemberIt(intAmt, 
/* 527 */                   memberId, detailId);
/*     */ 
/* 529 */                 nResult = nResult + this.integralConsumeRecordDAO
/* 529 */                   .insertIntgCrIt(detailId, billNo, 
/* 530 */                   intLog, bissId, memo);
/* 531 */                 decIntAmt = false;
/*     */               }
/*     */ 
/*     */             }
/*     */ 
/* 537 */             Integer sum = 
/* 538 */               Integer.valueOf(this.integralDetailDAO
/* 538 */               .selectIntAmtTotal(memberId));
/* 539 */             nResult += this.memberDAO.updateMemberIntAmt(sum, memberId);
/* 540 */            }
/* 541 */           return -1;
/*     */         }
/*     */ 
/* 545 */         return -4;
/*     */       }
/*     */ 
/* 550 */       if (payCashMny.doubleValue() > 0.0D) {
/* 551 */         label1023: detailIDsRslt = this.memberCashCouponDetailDAO
/* 552 */           .getSelectCashCouponDtialRslt(memberId, shopId);
/* 553 */         if ((detailIDsRslt != null) && (detailIDsRslt.getDataLength() > 0)) {
/* 554 */           Double memberCashCpon = Double.valueOf(0.0D);
/* 555 */           for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/* 556 */             Double cashCponTemp = 
/* 557 */               ObjectComm.objectToDouble(detailIDsRslt.getValueOfName(
/* 558 */               "FaceValue", i), Integer.valueOf(0));
/* 559 */             memberCashCpon = Double.valueOf(memberCashCpon.doubleValue() + cashCponTemp.doubleValue());
/*     */           }
/* 561 */           if (memberCashCpon.doubleValue() >= payCashMny.doubleValue()) {
/* 562 */             Double tempCashCpon = payCashMny;
/* 563 */             boolean decCashCpon = true;
/* 564 */             for (i = 0; i < detailIDsRslt.getDataLength(); ++i) {
/* 565 */               Double cashCpon = ObjectComm.objectToDouble(
/* 566 */                 detailIDsRslt
/* 567 */                 .getValueOfName("FaceValue", i), Integer.valueOf(0));
/* 568 */               detailId = (Long)detailIDsRslt
/* 569 */                 .getValueOfName("DetailID", i);
/* 570 */               Double cashLog = Double.valueOf(0.0D);
/* 571 */               if (tempCashCpon.doubleValue() - cashCpon.doubleValue() < 0.0D) {
/* 572 */                 cashLog = tempCashCpon;
/*     */               }
/* 574 */               tempCashCpon = Double.valueOf(tempCashCpon.doubleValue() - cashCpon.doubleValue());
/* 575 */               if (!(decCashCpon)) break;
/* 576 */               if (tempCashCpon.doubleValue() >= 0.0D)
/*     */               {
/* 578 */                 nResult = nResult + this.memberCashCouponDetailDAO
/* 578 */                   .updateCashCouponDtlStatusOfID(
/* 579 */                   memberId, detailId);
/*     */ 
/* 581 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/* 581 */                   .insertCashConpConsum(detailId, 
/* 582 */                   billNo, cashCpon, bissId, 
/* 583 */                   memo);
/* 584 */                 if (tempCashCpon.doubleValue() == 0.0D)
/* 585 */                   decCashCpon = false;
/*     */               }
/*     */               else {
/* 588 */                 cashCpon = Double.valueOf(cashCpon.doubleValue() - cashLog.doubleValue());
/*     */ 
/* 590 */                 nResult = nResult + this.memberCashCouponDetailDAO
/* 590 */                   .updateCashCouponMemberCs(cashCpon, 
/* 591 */                   memberId, detailId);
/*     */ 
/* 593 */                 nResult = nResult + this.memberCashCouponConsumeRecordDAO
/* 593 */                   .insertCashConpConsum(detailId, 
/* 594 */                   billNo, cashLog, bissId, 
/* 595 */                   memo);
/* 596 */                 decCashCpon = false;
/*     */               }
/*     */ 
/*     */             }
/*     */ 
/* 603 */             Double sum = this.memberCashCouponDetailDAO
/* 604 */               .selectSqlCashCouponDtlSum(memberId);
/* 605 */             nResult = this.memberDAO.updateMemberCashCoup(sum, memberId);
/* 606 */           }
/* 607 */           return -3;
/*     */         }
/*     */ 
/* 610 */         return -6;
/*     */       }
/*     */ 
/* 614 */       if (dDeposit.doubleValue() > 0.0D)
/*     */       {
/* 616 */         label1396: nResult = nResult + 
/* 616 */           PbPaid.getPositDeposit(dDeposit, memberId, billNo, 
/* 616 */           shopId, bissId, memo);
/* 617 */         if (nResult < 0)
/* 618 */           return nResult;
/*     */       }
/*     */       CSessionUser sessionUser;
/* 623 */       if (dCach.doubleValue() > 0.0D) {
/* 624 */         nResult += this.memberDAO.updateMemberInc(memberId, dCach);
/* 625 */         sessionUser = 
/* 626 */           UserSessionInfo.user_getUserOfRequest(request);
/*     */ 
/* 628 */         nResult = nResult + 
/* 628 */           PbPaid.getGivePresent(sessionUser, dCach, id, 
/* 628 */           memberId, stId, Boolean.valueOf(true), memo);
/* 629 */         if (nResult < 0) {
/* 630 */           return nResult;
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/* 636 */       if (dIntAmt.doubleValue() < 0.0D) {
/* 637 */         int nrst = 0;
/* 638 */         nrst = 
/* 639 */           PbPaid.getNtiveIntegral(bissId, dIntAmt.intValue(), memo);
/* 640 */         if (nrst < 0)
/* 641 */           return nrst;
/* 642 */         if ((nrst == 0) || (nrst > 0)) {
/* 643 */           nResult += nrst;
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/* 648 */       if (payCashMny.doubleValue() < 0.0D) {
/* 649 */         nResult += PbPaid.getNtiveCashConp(bissId, payCashMny, memo);
/* 650 */         if (nResult < 0) {
/* 651 */           return -7;
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/* 656 */       if (dDeposit.doubleValue() < 0.0D)
/*     */       {
/* 658 */         nResult = nResult + 
/* 658 */           PbPaid.getNtiveDopsit(dDeposit, memberId, billNo, 
/* 658 */           shopId, userName, bissId, memo);
/* 659 */         if (nResult < 0) {
/* 660 */           return nResult;
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/* 665 */       if (dCach.doubleValue() < 0.0D) {
/* 666 */         nResult += PbPaid.getNtiveCash(memberId, dCach, shopId);
/* 667 */         sessionUser = 
/* 668 */           UserSessionInfo.user_getUserOfRequest(request);
/*     */ 
/* 670 */         nResult = nResult + 
/* 670 */           PbPaid.getGivePresent(sessionUser, dCach, id, 
/* 670 */           memberId, stId, Boolean.valueOf(true), memo);
/* 671 */         if (nResult < 0) {
/* 672 */           return nResult;
/*     */         }
/*     */       }
/*     */ 
/* 676 */       GsonHeadOneRow pa = this.memberDAO.getPaidOneRowOfMemberId(memberId);
/* 677 */       if ((pa != null) && (pa.getDataLength() > 0)) {
/* 678 */         String sData = "data=" + pa.objectToJsonStr() + 
/* 679 */           "&" + "id" + "=" + memberId;
/* 680 */         String sUrl = "ptmember/editPaid";
/* 681 */         GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, 
/* 682 */           sData, response);
/* 683 */         if ((rst == null) || (rst.getState() != 0))
/* 684 */           return -14;
/*     */       }
/*     */       else {
/* 687 */         return -14;
/*     */       }
/*     */ 
/* 690 */       Object custId = r.getValueOfName("CustId");
/* 691 */       String custName = (String)r.getValueOfName("CustName");
/* 692 */       csMsg.setBillAmt(billAmt);
/* 693 */       csMsg.setBussId(bissId);
/* 694 */       csMsg.setStId(stId);
/* 695 */       csMsg.setCustId(custId);
/* 696 */       csMsg.setCustName(custName);
/* 697 */       csMsg.setIntAmt(ObjectComm.objectToInteger(dIntAmt, Integer.valueOf(0)));
/* 698 */       csMsg.setDeposit(dDeposit);
/* 699 */       csMsg.setCashConp(payCashMny);
/* 700 */       csMsg.setShopId(shopId);
/* 701 */       csMsg.setCash(dCach);
/* 702 */       csMsg.setDpsitConp(payDisctCoup);
/* 703 */       csMsg.setkCashConp(ObjectComm.objectToDouble(
/* 704 */         pa.getValueOfName("CashCouponAmount"), Integer.valueOf(0)));
/* 705 */       csMsg.setkDeposit(ObjectComm.objectToDouble(
/* 706 */         pa.getValueOfName("DepositAmount"), Integer.valueOf(0)));
/* 707 */       csMsg.setkDpsitConp(ObjectComm.objectToDouble(
/* 708 */         pa.getValueOfName("CouponAmount"), Integer.valueOf(0)));
/* 709 */       csMsg.setkIntAmt(ObjectComm.objectToInteger(
/* 710 */         pa.getValueOfName("IntegralAmount"), Integer.valueOf(0)));
/* 711 */       csMsg.setMp((String)r.getValueOfName("Mp"));
/* 712 */       csMsg.setCrTime(new Date());
/* 713 */       nResult += PbPaid.sendSMS(csMsg);
/* 714 */       if (nResult < 0) {
/* 715 */         return -16;
/*     */       }
/* 717 */       this.memberLogDAO
/* 718 */         .insertMemberLogBuss(MemberActConst.PAID, billNo, dIntAmt, 
/* 719 */         dDeposit, dCach, dCach, memberId, userId, userName);
/*     */     }
/* 721 */     return nResult;
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.bussBill.bpCheck.controller.BpCheckController
 * JD-Core Version:    0.5.3
 */